package com.heima.common.exception;


import com.heima.common.dto.ResponseResult;
import com.heima.common.enums.AppHttpCodeEnum;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.logging.Logger;


@Slf4j
@RestControllerAdvice
public class BaseExceptionHandler{

    @ExceptionHandler(Exception.class)
    public ResponseResult exceptionHandler(Exception e){ //用来处理程序员预知不到的异常
        e.printStackTrace();
        log.error(e.getMessage());
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }


}
